home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / Algae.as < prev    next >
Text File  |  2013-04-24  |  3KB  |  101 lines

  1. class Algae extends State
  2. {
  3.    static var sLINKAGE_NAME = "mcAlgae";
  4.    var sSTATE_IDLE = "Idle";
  5.    var sSTATE_CATCHING = "Catching";
  6.    var sSTATE_CAUGHT = "Caught";
  7.    var sSTATE_FALLING = "Falling";
  8.    var sSTATE_FALLEN = "Fallen";
  9.    var sSTATE_RETURN = "Return";
  10.    var nMAX_COUNTDOWN = 200;
  11.    static var nCOUNTER = 0;
  12.    static var nMIN_DEPTH = 200012;
  13.    static var nSUBSTRACT_DEPTH = 200000;
  14.    static var nDEPTH_FACTOR = 25;
  15.    static var nMIN_WAIT_TIME = 50;
  16.    static var nMAX_WAIT_TIME = 250;
  17.    function Algae(_nX, _nY)
  18.    {
  19.       super(CTRLGame.getRef().mcRef.attachMovie(Algae.sLINKAGE_NAME,Algae.sLINKAGE_NAME + Algae.nCOUNTER,this.calculateDepth(_nY,CTRLGame.nALGAE_ADD + Algae.nCOUNTER)));
  20.       Algae.nCOUNTER = Algae.nCOUNTER + 1;
  21.       this.mcRef._x = _nX;
  22.       this.mcRef._y = _nY;
  23.       this.setIdleState();
  24.       this.nCountDown = 0;
  25.       if(Controller.getRef().isPaused())
  26.       {
  27.          this.doPause();
  28.       }
  29.    }
  30.    function cleanUp()
  31.    {
  32.       super.cleanUp();
  33.       this.mcRef.swapDepths(7777);
  34.       this.mcRef.removeMovieClip();
  35.    }
  36.    function catchBus()
  37.    {
  38.       this.setState(this.sSTATE_CATCHING);
  39.    }
  40.    function setInactive()
  41.    {
  42.       this.setState(this.sSTATE_FALLING);
  43.       this.nCountDown = this.nMAX_COUNTDOWN;
  44.       this.mcRef.swapDepths(this.mcRef.getDepth() - Algae.nSUBSTRACT_DEPTH);
  45.    }
  46.    function isInactive()
  47.    {
  48.       return this.sState != this.sSTATE_IDLE;
  49.    }
  50.    function setIdleState()
  51.    {
  52.       var _loc2_ = Math.round(Math.random() * 42) + 1;
  53.       this.setState(this.sSTATE_IDLE);
  54.       this.mcRef.mcState.gotoAndPlay(_loc2_);
  55.    }
  56.    function calculateDepth(_nY, _nAdd)
  57.    {
  58.       var _loc4_ = Math.round(_nY) * Algae.nDEPTH_FACTOR + Algae.nMIN_DEPTH + _nAdd;
  59.       return _loc4_;
  60.    }
  61.    function Idle()
  62.    {
  63.    }
  64.    function Catching()
  65.    {
  66.       if(this.stateFinished())
  67.       {
  68.          this.setState(this.sSTATE_CAUGHT);
  69.       }
  70.    }
  71.    function Caught()
  72.    {
  73.    }
  74.    function Falling()
  75.    {
  76.       if(this.stateFinished())
  77.       {
  78.          this.setState(this.sSTATE_FALLEN);
  79.       }
  80.    }
  81.    function Fallen()
  82.    {
  83.       if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
  84.       {
  85.          this.nCountDown = this.nCountDown - 1;
  86.          if(this.nCountDown <= 0)
  87.          {
  88.             this.setState(this.sSTATE_RETURN);
  89.          }
  90.       }
  91.    }
  92.    function Return()
  93.    {
  94.       if(this.stateFinished())
  95.       {
  96.          this.setIdleState();
  97.          this.mcRef.swapDepths(this.mcRef.getDepth() + Algae.nSUBSTRACT_DEPTH);
  98.       }
  99.    }
  100. }
  101.